import 'package:chat/common/widgets/Avatar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Chat extends StatelessWidget {
  final bool isMe;
  final String content;
  final String userAvatar;
  final String friendAvatar;

  Chat({super.key, required this.isMe, required this.content, required this.userAvatar, required this.friendAvatar});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
      child: Row(
        mainAxisAlignment: isMe ? MainAxisAlignment.end : MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 左侧头像（自己发的不显示在左边）
          if (!isMe) Avatar(radius: 18, avatar: friendAvatar),

          // 间距
          const SizedBox(width: 8),

          // 聊天气泡
          Flexible(
            child: Padding(
              padding: const EdgeInsets.only(top: 15),
              child: Container(
                padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
                decoration: BoxDecoration(color: isMe ? Colors.blueAccent : Colors.white, borderRadius: BorderRadius.circular(16)),
                child: Text(content, style: TextStyle(color: isMe ? Colors.white : Colors.black87, fontSize: 16)),
              ),
            ),
          ),

          // 间距
          const SizedBox(width: 8),

          // 右侧头像（自己发的显示在右边）
          if (isMe) Avatar(radius: 18, avatar: userAvatar),
        ],
      ),
    );
  }
}
